package com.gcxy.controller;


import com.gcxy.core.R;
import com.gcxy.dto.semester.SemesterInfoDTO;
import com.gcxy.dto.semester.SemesterPageDTO;
import com.gcxy.service.SemesterService;
import com.gcxy.vo.semester.SemesterInfoVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 学期信息 前端控制器
 * </p>
 *
 * @author Huang先森
 * @since 2024-07-22
 */
@Api(tags = "学期管理")
@RestController
@RequestMapping("/semester")
public class SemesterController {

    @Resource
    private SemesterService semesterService;

    @ApiOperation("新增学期信息")
    @PostMapping("/insertSemester")
    public R<?> insertSemester(@RequestBody @Validated SemesterInfoDTO semesterInfoDTO){
        return semesterService.insertSemester(semesterInfoDTO);
    }

    @ApiOperation("获取学期列表")
    @GetMapping("/getSemesterPageByCondition")
    public R<?> getSemesterPageByCondition(SemesterPageDTO semesterPageDTO){
        return semesterService.getSemesterPageByCondition(semesterPageDTO);
    }

    @ApiOperation("更新学期信息")
    @PutMapping("/updateSemester")
    public R<?> updateSemester(@RequestBody @Validated SemesterInfoDTO semesterInfoDTO) {
        return semesterService.updateSemester(semesterInfoDTO);
    }

    @ApiOperation("删除学期信息")
    @DeleteMapping("/deleteSemesterById/{id}")
    public R<?> deleteSemesterById(@PathVariable Integer id) {
        return semesterService.deleteSemesterById(id);
    }

    @ApiOperation("获取所有学期信息")
    @GetMapping("/getAllSemesterInfo")
    public R<List<SemesterInfoVO>> getAllSemesterInfo(){
        return semesterService.getAllSemesterInfo();
    }

}

